package com.xdb.sqlparser.dialect.oracle.ast.expr;

import com.xdb.sqlparser.ast.expr.AbstractSQLNumericLiteralExpr;
import com.xdb.sqlparser.dialect.oracle.visitor.OracleASTVisitor;
import com.xdb.sqlparser.visitor.SQLAstVisitor;

public class OracleBinaryFloatExpr extends AbstractSQLNumericLiteralExpr implements OracleExpr {

	private Float value;

	public OracleBinaryFloatExpr() {

	}

	public OracleBinaryFloatExpr(Float value) {
		super();
		this.value = value;
	}

	@Override
	public Number getNumber() {
		return value;
	}

	public Float getValue() {
		return value;
	}

	public void setValue(Float value) {
		this.value = value;
	}

	@Override
	protected void accept0(SQLAstVisitor visitor) {
		accept0((OracleASTVisitor) visitor);
	}

	public void accept0(OracleASTVisitor visitor) {
		visitor.visit(this);
		visitor.endVisit(this);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		OracleBinaryFloatExpr other = (OracleBinaryFloatExpr) obj;
		if (value == null) {
			if (other.value != null) {
				return false;
			}
		} else if (!value.equals(other.value)) {
			return false;
		}
		return true;
	}

	@Override
	public void setNumber(Number number) {
		if (number == null) {
			this.setValue(null);
			return;
		}

		this.setValue(number.floatValue());
	}

}
